<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title></title>
	<script src="js\mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js\update.js" type="text/javascript" charset="utf-8"></script>
	<script src="js\mui.picker.min.js" type="text/javascript" charset="utf-8"></script>
	<link href="css\app.css"  rel="stylesheet"  type="text/css"/>
	<link href="css\mui.min.css" rel="stylesheet"  type="text/css"/>
	<link href="css\mui.picker.min.css" rel="stylesheet"  type="text/css"/>
	<script src="js\jquery.js" type="text/javascript" charset="utf-8"></script>
	<style>
			html,
			body,
			.mui-content {
				height: 0px;
				margin: 0px;
				background-color: #efeff4;
			}
			h5.mui-content-padded {
				margin-left: 3px;
				margin-top: 20px !important;
			}
			h5.mui-content-padded:first-child {
				margin-top: 12px !important;
			}
			.mui-btn {
				font-size: 16px;
				padding: 8px;
				margin: 3px;
			}
			.ui-alert {
				text-align: center;
				padding: 20px 10px;
				font-size: 16px;
			}
			* {
				-webkit-touch-callout: none;
				-webkit-user-select: none;
			}
			.mui-input-group{
				margin: 3px;
			}
			.bottomNavigation {
			    width:100%;
			    height:50px;
			    margin:0 auto;
			    background:#CCCCCC;
			    position:fixed;
			    bottom:0;
			    text-align:center;
				display: flex;
			}
			.button1{
				width:33.33%;
				height: 100%;
				border: none;
				box-sizing: border-box;
				border-left: 1px solid #cfcece;
				border-radius: 0;
			}
			.td1{width: 30%;}
			.td2{width: 30%;}
			.td3{width: 30%;text-align: right;}

		</style>
	<script type="text/javascript">
		function toActivity(activityName){
			order.toActivity(activityName);
		}

		//点击查询按钮-->调用接口进行查询
		//从第几条开始
			startPage=1;//定义全局变量
			pageCount=3;//每页加载几条
		    str="";//写入页面
		function selectOrderShow(){
			//获取查询条件的值
			var v=document.getElementById("result").innerText;
			var month=v.substring(6,13);//您还未选择时间 ,时间格式 2018-06
			var name=document.getElementById("name").value;//姓名 买家姓名（暂定）
			var payment=document.getElementById("community").value;//支付方式 1微信支付 2支付宝 3刷卡 4现金 0延迟支付
			//调用android方法请求接口，得到查询结果。
			//alert("month:"+month+","+"name:"+name+","+"payment:"+payment);
			var result=order.selectOrderInterface(month,name,payment,startPage,pageCount);
			//定义静态返回值
			//var json={"code" : "0","message" : "成功分页查询订单列表","data" : {"orderTotalAmount" : 7000,"orderCount" : 3,"orderList" : [ {"orderId" : "efc49537db5c4d8d9b452c4343e89437","totalAmount" : 5500,"mechantId" : "admin","truckId" : "2","operatorId" : "3","createTime" : "2018-07-17 14:53:28","orderPay" : {"orderId" : "efc49537db5c4d8d9b452c4343e89437","buyerId" : "000000","tradeNo" : null,"mechantOrderNo" : null,"orderState" : 2,"payType" : null,"payAmount" : 4300,"subsidyAmount" : 200,"subsidyProportion" : 20,"createTime" : "2018-07-17 14:53:28","updateTime" : "2018-07-17 15:43:07","orderStateStr" : "取消支付","payTypeStr" : null},"goodsList" : [ {"orderId" : "efc49537db5c4d8d9b452c4343e89437","goodsId" : "d6c56036b3194693a9e012f4deb01c20","goodsPrice" : 2000,"goodsAmount" : 2.00,"goodsUnit" : "0","createTime" : "2018-07-17 14:53:28","goodsUnitStr" : "个"},{"orderId" : "efc49537db5c4d8d9b452c4343e89437","goodsId" : "d6c56036b3194693a9e012f4deb01c20","goodsPrice" : 2000,"goodsAmount" : 2.00,"goodsUnit" : "0","createTime" : "2018-07-17 14:53:28","goodsUnitStr" : "个"} ]},{"orderId" : "efc49537db5c4d8d9b452c4343e89437","totalAmount" : 5500,"mechantId" : "admin","truckId" : "2","operatorId" : "3","createTime" : "2018-07-17 14:53:28","orderPay" : {"orderId" : "efc49537db5c4d8d9b452c4343e89437","buyerId" : "000000","tradeNo" : null,"mechantOrderNo" : null,"orderState" : 2,"payType" : null,"payAmount" : 4300,"subsidyAmount" : 200,"subsidyProportion" : 20,"createTime" : "2018-07-17 14:53:28","updateTime" : "2018-07-17 15:43:07","orderStateStr" : "取消支付","payTypeStr" : null},"goodsList" : [ {"orderId" : "efc49537db5c4d8d9b452c4343e89437","goodsId" : "d6c56036b3194693a9e012f4deb01c20","goodsPrice" : 2000,"goodsAmount" : 2.00,"goodsUnit" : "0","createTime" : "2018-07-17 14:53:28","goodsUnitStr" : "个"} ]} ],"orderPayAmount" : 4300}}
			json=$.parseJSON(result);
			//alert(json);

				//设置 、总数和交易金额
				var orderPayAmount=json.data.orderPayAmount;//订单实付总额
				var orderTotalAmount=json.data.orderTotalAmount;//订单原价总额
				var orderCount=json.data.orderCount;//订单数量
				document.getElementById("orderCount").innerText=orderCount+"笔";
				document.getElementById("orderTotalAmount").innerText=orderTotalAmount/100+"元";
				document.getElementById("orderPayAmount").innerText=orderPayAmount/100+"元";
				//遍历订单list
				var orderList1=json.data.orderList;
				orderList=eval(orderList1);
				//alert(orderList);
				for(var key in orderList){
//					alert(orderList[key].totalAmount);//本订单原价
//					alert(orderList[key].orderPay.payAmount);//本订单实付
//					alert(orderList[key].orderPay.subsidyAmount);//本订单补贴金额
//					alert(orderList[key].orderPay.tradeNo);//流水订单号
//					alert(orderList[key].orderPay.mechantOrderNo);//商户系统内部订单号
//					alert(orderList[key].operatorId);//操作员id
//					alert(orderList[key].orderPay.buyerId);//买家id
						str+="<ul class='mui-table-view'>"+
				 "<li class='mui-table-view-cell'>"+
				 		"<div id='mydiv' >"+
							"<table border='0' cellspacing='' cellpadding='' class='myTable' width='100%' bgcolor='#E6E6E6' style='color:#388E8E ;'>"+
								"<tr height='30px'>"+
								"<td style='text-align: center;color:#388E8E;'colspan='3'>"+"订单"+"</td>"+
								"</tr>";
					var goodsList1=orderList[key].goodsList;
					goodsList=eval(goodsList1);
					//alert(goodsList);
					for(var _key in goodsList){
//						alert(goodsList[_key].goodsId);//商品id
//						alert(goodsList[_key].goodsAmount);//商品数量
//						alert(goodsList[_key].goodsPrice);//商品价格
								str+="<tr height='30px'>"+
									"<td class='td1'>"+"固定商品"+"</td>"+
									"<td class='td2'>"+goodsList[_key].goodsAmount+"</td>"+
									"<td class='td3'>"+goodsList[_key].goodsPrice/100+"元"+"</td>"+
								"</tr>";

					}

				 		str+="<tr height='10px'>"+
								"</tr>"+
							"</table>"+
				 			"<table border='0' cellspacing='' cellpadding=''width='100%'style='color:#388E8E ;'>"+
								"<tr>"+
								"<td width='60%'>"+"原价："+"</td>"+
								"<td style='text-align: right;'>"+orderList[key].totalAmount/100+"元"+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"补贴："+"</td>"+
								"<td style='text-align: right;'>"+orderList[key].orderPay.subsidyAmount/100+"元"+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"应付："+"</td>"+
								"<td style='text-align: right;'>"+orderList[key].orderPay.payAmount/100+"元"+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"当日已用消费额度："+"</td>"+
								"<td style='text-align: right;'>"+"暂无数据"+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"当日剩余消费额度："+"</td>"+
								"<td style='text-align: right;'>"+"暂无数据"+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"订单号："+"</td>"+
								"<td style='text-align: right;'>"+orderList[key].orderPay.tradeNo+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"操作员："+"</td>"+
								"<td style='text-align: right;'>"+orderList[key].operatorId+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+"客户号："+"</td>"+
								"<td style='text-align: right;'>"+orderList[key].orderPay.buyerId+"</td>"+
								"</tr>"+
								"<tr>"+
								"<td >"+""+"</td>"+
								"<td>"+""+"</td>"+
								"</tr>"+
							"</table>"+
							"</div>"+
				 "</li>"+
				 "</ul>";

				}
			document.getElementById("showResult").innerHTML=str;
			startPage++;//设置下一次查询第几页
		}
		//点击查询时，先清空订单列表，在查询，
		function clearAndSelect(){
			str="";
			document.getElementById("showResult").innerHTML=str;
			startPage=1;
			selectOrderShow();
		}
	</script>
</head>
<body>
<header id="header" class="mui-bar mui-bar-nav">
	<h1 class="mui-title">订单</h1>
</header>
<a name="_top"></a>
<div class="mui-content">
	<div class="mui-card">
		<ul class="mui-table-view">
			<li class="mui-table-view-cell">本月订单数 <span class="mui-badge" id="orderCount">0笔</span></li>
			<li class="mui-table-view-cell">本月订单原价总额 <span class="mui-badge" id="orderTotalAmount">0元</span></li>
			<li class="mui-table-view-cell">本月订单实付总额 <span class="mui-badge" id="orderPayAmount">0元</span></li>
		</ul>
	</div>

	<div class="mui-content-padded">
		<form class="mui-input-group">
			<div class="mui-input-row">
				<label>买家id:</label>
				<input style="font-size: 0.93em" type="text" placeholder="请输入" id="name">
			</div>
			<div class="mui-input-row" >
				<label>支付方式:</label>
				<select id="community" style="font-size: 0.93em">
					<option  value="">请选择</option>
					<option  value="0">微信支付</option>
					<option value="1">支付宝支付</option>
					<option value="2">刷卡支付</option>
					<option value="3">现金支付</option>
					<option value="4">延迟支付</option>
				</select>
			</div>
			<div class="mui-input-row" id="demo6" data-options="{&quot;type&quot;:&quot;month&quot;}">
				<label>选择月份</label>
				<input style="font-size: 0.93em;cursor: pointer" id="result" type="text" placeholder="请选择" readonly>
			</div>
		</form>
		<!--<div class="mui-card">
            <ul class="mui-table-view mui-table-view-chevron">
                <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">支付类型</a>
                    <ul class="mui-table-view mui-table-view-chevron">
                        <li class="mui-table-view-cell"><a class="mui-navigate-right" href="#">微信支付</a>
                        </li>
                        <li class="mui-table-view-cell"><a class="mui-navigate-right" href="#">支付宝支付</a>
                        </li>
                        <li class="mui-table-view-cell"><a class="mui-navigate-right" href="#">刷卡支付</a>
                        </li>
                        </li>
                        <li class="mui-table-view-cell"><a class="mui-navigate-right" href="#">现金支付</a>
                        </li>
                        </li>
                        <li class="mui-table-view-cell"><a class="mui-navigate-right" href="#">延迟支付</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>-->

		<!--<button id="demo6" data-options="{&quot;type&quot;:&quot;month&quot;}" class="btn mui-btn mui-btn-block">选择月份 ...</button>-->
		<!--<div id="result" class="ui-alert">选择结果: 您还未选择月份</div>-->

		<button type="button" style="margin-top: 1em" class="mui-btn mui-btn-success mui-btn-block" onclick="clearAndSelect()">查询</button>
	</div>
	<div id="showResult">
		<!--<ul class="mui-table-view">
             <li class="mui-table-view-cell">查询结果</li>
        </ul>-->
	</div>
	<div id="" align="center" style="height: 100px;">
		<a href="javaScript:void(0)" onclick="selectOrderShow()"id="pullDown">点击加载</a>&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="#_top" style="color: chocolate;" >返回顶部</a>
	</div>
</div>

<div class="bottomNavigation">
	<!--onclick="showItems()"-->
	<button class="button1" onclick="toActivity('HomePageActivity')">首页</button>
	<button class="button1" onclick="toActivity('CreateCompleteFileActivity')">建档</button>
	<button class="button1" onclick="toActivity('PersonalCenterActivity')">我的</button>
</div>
<script>
			(function($) {
				$.init();
				var result = $('#result')[0];
				var btns = $('#demo6');
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var optionsJson = this.getAttribute('data-options') || '{}';
						var options = JSON.parse(optionsJson);
						var id = this.getAttribute('id');
						/*
						 * 首次显示时实例化组件
						 * 示例为了简洁，将 options 放在了按钮的 dom 上
						 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
						 */
						var picker = new $.DtPicker(options);
						picker.show(function(rs) {
							/*
							 * rs.value 拼合后的 value
							 * rs.text 拼合后的 text
							 * rs.y 年，可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
							 * rs.m 月，用法同年
							 * rs.d 日，用法同年
							 * rs.h 时，用法同年
							 * rs.i 分（minutes 的第二个字母），用法同年
							 */
							result.value = rs.text;
							/* 
							 * 返回 false 可以阻止选择框的关闭
							 * return false;
							 */
							/*
							 * 释放组件资源，释放后将将不能再操作组件
							 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。
							 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。
							 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。
							 */
							picker.dispose();
						});
					}, false);
				});
			})(mui);
		</script>
</body>
</html>